package com.example.administrator.testdate;

import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

public class MainActivity_ONT extends AppCompatActivity {
    static Handler handler = new Handler();
    static Runnable runnable = new Runnable() {

        @Override
        public void run() {

            Log.i("tag","hahaahahha");
            handler.postDelayed(runnable, 1000);
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        Button mButtonStart = (Button) findViewById(R.id.button1);
//        Button mButtonStop = (Button) findViewById(R.id.button2);
//
//        mButtonStart.setOnClickListener(new OnClickListener() {
//
//            @Override
//            public void onClick(View v) {
//                handler.post(runnable);
//            }
//        });
//
//        mButtonStop.setOnClickListener(new OnClickListener() {
//
//            @Override
//            public void onClick(View v) {
//                handler.removeCallbacks(runnable);
//            }
//        });
        for (int i=0;i<5;i++){
            if (i<5){
//                handler.post(runnable);
                handler.postDelayed(runnable,1000);
            }else{
                handler.removeCallbacks(runnable);
            }
        }
    }
}
